package org.xdq.test;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.xdq.demo.config.MyConfig;
import org.xdq.demo.dao.EmpDao;
import org.xdq.demo.dto.EmpDto;
import org.xdq.demo.dto.EmpQueryDto;
import org.xdq.demo.model.Emp;
import org.xdq.demo.my.A;
import org.xdq.demo.service.MyService;

import java.util.List;
import java.util.Map;

@SpringJUnitConfig(MyConfig.class)
@Slf4j
public class MyTest01 {


    @Autowired
    private EmpDao empDao;

    @Test
    public void t1(){
        int empCount = empDao.findEmpCount();
        log.debug("empCount={}",empCount);

    }

    @Test
    public void t2(){
        EmpQueryDto dto = new EmpQueryDto();
        dto.setE_name("88");
        List<Emp> empList = empDao.findEmpList(dto);

        empList.forEach(emp -> log.debug("{}",emp));


    }

    @Test
    public void t3(){
        EmpDto dto = new EmpDto(
                "02001","员工02001",1,null,0,null);
        empDao.insertNewEmp(dto);
    }

    @Autowired
    private MyService myService;
    @Test
    public void t4(){
        EmpDto dto1 = new EmpDto(
                "02006","员工02006",1,null,0,null);
        EmpDto dto2 = new EmpDto(
                "02007","员工02007",1,null,0,null);
        myService.saveSomeEmps(dto1,dto2);
    }

    @Test
    public void t5() throws Exception {
        EmpQueryDto dto = new EmpQueryDto();
        dto.setE_name("88");
        dto.setPageNum(2);
        dto.setPageSize(3);

        Map<String, Object> empPage = myService.getEmpPage(dto);

        log.debug("{}",empPage);

    }



}
